#!/usr/local/bin/ruby
# Copyright (C) 2003-2010 Wang Pengcheng <wpc0000@gmail.com>
# , released under the MIT license
# You may obtain a template of the MIT License at
# http://www.opensource.org/licenses/mit-license.php
$KCODE = 'utf8'

require 'gtk2'

class DoItBasic
  def doIt(m)
    puts m+':from basic do it'
  end
end

class PutToStd < DoItBasic
  def doIt(m)
    puts m
  end
end

class PutToStd < DoItBasic

  # Function to open a dialog box displaying the message provided.
  def quick_message(message)
    # Create the dialog
    dialog = Gtk::Dialog.new("Message",
                             $main_application_window,
                             Gtk::Dialog::DESTROY_WITH_PARENT,
                             [ Gtk::Stock::OK, Gtk::Dialog::RESPONSE_NONE ])

    # Ensure that the dialog box is destroyed when the user responds.
    dialog.signal_connect('response') {
      dialog.destroy
      Gtk.main_quit
    }

    # Add the message in a label, and show everything we've added to the dialog.
    dialog.vbox.add(Gtk::Label.new(message))
    dialog.show_all
    Gtk.main
  end

  def doIt(m)
    quick_message(m)
  end

end

class Balloon < DoItBasic
  @@ExTime=1000*60*60
  def doIt(m)
    %x[/usr/bin/notify-send -t #{@@ExTime} "#{Time.now}" "#{m}"]
  end
end

